package langdetect;

import java.io.File;
import java.util.Scanner;

public class Test {

  public static void main(String[] args) {
    String content = "";
    for ( int i = 1; i < 5; i++ ) {
      System.out.println();
      System.out.println("============= Running File: us-news-" + i + " =============");
      File news = new File(ClassLoader.getSystemResource("test-data/us-news-" + i).getFile());
      try ( Scanner scanner = new Scanner(news).useDelimiter("\\Z") ) {
        content = scanner.next();
      } catch ( Exception e ) { 
        e.printStackTrace();
      }
      
      for ( LDModel m : LDModel.values() ) {
        try {
          LangDetector ld = new LangDetector(m, 0.9d);
          ld.inputText = content;
          ld.execute();
          System.out.println(ld);
        } catch ( UnsupportedOperationException e ) {
          System.out.println(e.getMessage());
        }
      }
    }
    
    for ( int i = 1; i < 5; i++ ) {
      System.out.println();
      System.out.println("============= Running File: int-news-" + i + " =============");
      File news = new File(ClassLoader.getSystemResource("test-data/int-news-" + i).getFile());
      try ( Scanner scanner = new Scanner(news).useDelimiter("\\Z") ) {
        content = scanner.next();
      } catch ( Exception e ) { 
        e.printStackTrace();
      }
      
      for ( LDModel m : LDModel.values() ) {
        try {
          LangDetector ld = new LangDetector(m, 0.9d);
          ld.inputText = content;
          ld.execute();
          System.out.println(ld);
        } catch ( UnsupportedOperationException e ) {
          System.out.println(e.getMessage());
        }
      }
    }
  }
}